﻿@{
    ViewData["Title"] = "PowerList";
    Layout = "~/Views/_ViewImports.cshtml";
}
<script src="~/js/SystemManager/PowerList.js"></script>

<table id="power" lay-filter="power"></table>

@*头部工具栏*@
<script type="text/html" id="heard_tool">
     <div class="layui-row layui-col-space15 layui-form" lay-filter="lanbt-head-tool">
            <div class="layui-col-md1">
        <select name="status" >
          <option value="">状态</option>
          <option value="true">启用</option>
          <option value="false">禁用</option>
        </select>
      </div>
          <div class="layui-col-md1">
        <select name="showType" >
          <option value="">显示类型</option>
          <option value="true">显示</option>
          <option value="false">隐藏</option>
        </select>
      </div>
            
      <div class="layui-col-md2">
        <input type="text" name="name" placeholder="权限名" autocomplete="off" class="layui-input">
      </div>
      <div class="layui-col-md2">
        <input type="text" name="menuCode" placeholder="菜单编号" autocomplete="off" class="layui-input">
      </div>
      <div class="layui-col-md1">
        <input type="text" name="parentID" placeholder="父节点ID" autocomplete="off" class="layui-input">
      </div>
      <div class="layui-col-md1">
        <select name="powerType" >
          <option value="0">节点类型</option>
          <option value="1">文件夹</option>
          <option value="2">页面</option>
          <option value="3">按钮</option>
          <option value="4">权限</option>
        </select>
      </div>
      <div class="layui-col-md3">
        <a class="layui-btn layui-btn-sm power-show" lay-event="search" title="搜索" lay-menu-code="SystemManagerAction:QueryPagedPowerList" ><i class="layui-icon layui-icon-search" /></a>
        <a class="layui-btn layui-btn-sm power-show" lay-event="add" title="添加" lay-menu-code="SystemManagerAction:InsertPower" ><i class="layui-icon layui-icon-addition" /></a>
        <a class="layui-btn layui-btn-sm power-show" lay-event="batchDel" title="批量删除" lay-menu-code="SystemManagerAction:DeletePowerByIds" ><i class="layui-icon layui-icon-delete" /></a>
      </div>
    </div>
</script>

@*行工具栏*@
<script type="text/html" id="line_tool">
    {{# if(d.powerType != 3 && d.powerType != 4){ }}
        <a class="layui-btn layui-btn-xs power-show" lay-event="addChildren" lay-menu-code="SystemManagerAction:Insert:Children" title="添加子项" ><i class="iconfont icon-a-bianzu13-43"></i></a>
        <a class="layui-btn layui-btn-xs power-show" lay-event="showOrHide" lay-menu-code="SystemManagerAction:UpdateMenuShowOrHide" >
            {{# if(d.isMenuShow){ }}
            <i class="iconfont icon-hide" title="隐藏"></i>
            {{# }else{ }}
            <i class="iconfont icon-show" title="显示"></i>
            {{# } }}
        </a>
    {{# } }}
    <a class="layui-btn layui-btn-xs power-show" lay-event="updateEnable" lay-menu-code="SystemManagerAction:UpdateMenuEnable" >
            {{# if(d.isEnable){ }}
        @*<i class="iconfont icon-hide" title="隐藏"></i>*@禁用
            {{# }else{ }}
        @*<i class="iconfont icon-show" title="显示"></i>*@启用
            {{# } }}
        </a>
    <a class="layui-btn layui-btn-xs power-show" lay-event="edit" title="编辑" lay-menu-code="SystemManagerAction:UpdatePower" ><i class="layui-icon layui-icon-edit" /></a>
    <a class="layui-btn layui-btn-xs power-show" lay-event="delete" title="删除" lay-menu-code="SystemManagerAction:DeletePowerById" ><i class="layui-icon layui-icon-delete" /></a>
</script>

@*添加/修改权限*@
<template id="power-template">
    <script src="~/lib/layui/xm-select.js"></script>
    <ul class="layui-form layui-form-pane" style="margin:15px;" lay-filter="form">
        <li class="layui-form-item layui-hide">
            <div class="layui-input-block">
                <input type="text" name="id" autocomplete="off" class="layui-input">
            </div>
        </li>
        <li class="layui-form-item">
            <label class="layui-form-label">权限名：</label>
            <div class="layui-input-block">
                <input type="text" name="name" required lay-verify="required" placeholder="请输入权限名" autocomplete="off" class="layui-input">
            </div>
        </li>
        <li class="layui-form-item">
            <label class="layui-form-label">菜单编码：</label>
            <div class="layui-input-block">
                <textarea name="menuCode" placeholder="请输入菜单编码" class="layui-textarea"></textarea>
            </div>
        </li>
        <li class="layui-form-item">
            <label class="layui-form-label">父节点：</label>
            <div class="layui-input-block">
                <div class="xm-select-demo-alert" id="parentID"></div>
            </div>
        </li>
        <li class="layui-form-item">
            <label class="layui-form-label">节点类型：</label>
            <div class="layui-input-block">
                <div class="xm-select-demo-alert" id="powerType"></div>
            </div>
        </li>
        <li class="layui-form-item">
            <label class="layui-form-label">图标：</label>
            <div class="layui-input-inline" style="width: 65%;">
                <input type="text" name="iconUrl" autocomplete="off" class="layui-input">
            </div>
            <a class="layui-form-mid layui-word-aux" href="http://layui.org.cn/doc/element/icon.html#table" target="_blank">选择图标</a>
        </li>
        <li class="layui-form-item">
            <label class="layui-form-label">页面地址：</label>
            <div class="layui-input-block">
                <input type="text" name="lineUrl" placeholder="请输入页面地址" autocomplete="off" class="layui-input">
            </div>
        </li>
        <li class="layui-form-item">
            <label class="layui-form-label">备注：</label>
            <div class="layui-input-block">
                <textarea name="descript" placeholder="请输入备注" class="layui-textarea"></textarea>
            </div>
        </li>
        <li class="layui-form-item" style="text-align:center">
            <button type="submit" class="layui-btn" lay-submit lay-filter="save" title="保存">保存</button>
        </li>
    </ul>

    <script>

        //初始化父级id选择框
        var parentIDSelect = xmSelect.render({
            el: '#parentID',
            name: 'parentID',//自定义name
            layVerify: 'required',//验证
            layVerType: 'msg',//验证弹出类型
            filterable: true,//开启搜索
            language: 'zn',
            radio: true,
            clickClose: true,
            model: {
                label: {
                    type: 'text',
                    text: {
                        //左边拼接的字符
                        left: '',
                        //右边拼接的字符
                        right: '',
                        //中间的分隔符
                        separator: ', ',
                    },
                }
            },
            data: []
        });

        //初始化节点类型选择框
        var powerTypeSelect = xmSelect.render({
            el: '#powerType',
            name: 'powerType',
            layVerify: 'required',
            layVerType: 'msg',
            language: 'zn',
            radio: true,
            clickClose: true,
            model: {
                label: {
                    type: 'text',
                    text: {
                        //左边拼接的字符
                        left: '',
                        //右边拼接的字符
                        right: '',
                        //中间的分隔符
                        separator: ', ',
                    },
                }
            },
            data: [
                { name: '文件夹', value: '1' },
                { name: '页面', value: '2' },
                { name: '按钮', value: '3' },
                { name: '权限', value: '4' },
            ]
        });

        layui.use(['comment'], function () {
            var comment = layui.comment
                , $ = layui.$;

            comment._ACP(ApiUrl.LanbtPower.SelectQuery, {}, function (res) {
                if (res.success) {
                    parentIDSelect.update({
                        data: res.result,
                    });
                } else {
                    layer.msg("数据获取失败，请联系管理员")
                }
            })


        })

    </script>

</template>